package chapter17;

/**
 * @Auther: Tx
 * @Date: 2022/6/19 19:52
 */
//1.join方法
public class ThreadMethod01 {
    public static void main(String[] args) throws InterruptedException {
        T t = new T();
        t.start();
       t.join();//有join的话就会先执行完join的线程，否则就会并发执行
        for (int i = 0; i < 20; i++) {
            Thread.sleep(50);
            System.out.println("主线程"+i);
        }
    }

}
class T extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Join Thread"+i);
        }
    }
}